類別繼承範例

#C#

Posted by Phyxsius on 2023-09-14

using System.Security.Cryptography.X509Certificates;

internal class Program
{
    private static void Main(string[] args)
    {
        Console.WriteLine("Hello, World!");

        B b = new B("x",100);
        b.show();

        C c = new C("y",200);
        c.show();
    }
}

class A
{
    public A(string a, int b)
    {

    }

    public void show()
    {
        Console.WriteLine("A  Class");
    }
}

class B:A
{
    public B(string x, int y) : base(x,y)
    {

    }
}

class C:B
{
    public C(string x, int y):base(x,y)
    {

    }

    public new void show()
    {
        Console.WriteLine("C  Class");
    }
}

#C#







Related Posts

DAY10:Is this a triangle?

DAY10:Is this a triangle?

Week1 筆記|[MTR04] 前後端整體架構說明 筆記

Week1 筆記|[MTR04] 前後端整體架構說明 筆記

2022 實習面試心得(聯發科/智邦科技/創未來/Nvidia/HP惠普實習星/DELL/Amazon ring/華邦電子)

2022 實習面試心得(聯發科/智邦科技/創未來/Nvidia/HP惠普實習星/DELL/Amazon ring/華邦電子)


Comments